package cn.edu.scau.cmi.shishuai.comprehensiveExperiment;

import cn.edu.scau.cmi.shishuai.domain.Meat;
import cn.edu.scau.cmi.shishuai.factory.BeefMeatFactory;
import cn.edu.scau.cmi.shishuai.factory.ChickenMeatFactory;
import cn.edu.scau.cmi.shishuai.factory.MeatFactory;
import cn.edu.scau.cmi.shishuai.factory.PorkMeatFactory;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class FactoryUI {
	
	@FXML
	private TextField tf;
	
	@FXML
	private TextArea ta;
	
	@FXML
	public void onTF(ActionEvent av) throws Exception {
		String meatName = tf.getText();
		MeatFactory meatFactory;
		Meat meat;
		ta.clear();
		switch(meatName) {
		case "beef": meatFactory=new BeefMeatFactory(); meat = meatFactory.getInstance();  ta.appendText(meat.cook1()); break;
		case "pork": meatFactory=new PorkMeatFactory();meat = meatFactory.getInstance();  ta.appendText(meat.cook1()); break;
		case "chicken": meatFactory=new ChickenMeatFactory();meat = meatFactory.getInstance();  ta.appendText(meat.cook1()); break;
		default:ta.appendText("sorry, your input is not correct");
		
		}
	} 
	

}
